|
Algorithms for calculating variance play a major role in computational statistics. A key problem in the design of good algorithms for this problem is that formulas for the variance may involve sums of squares, which can lead to numerical instability as well as to arithmetic overflow when dealing with large values. ==Naïve algorithm== A formula for calculating the variance of an entire population of size ''N'' is: : Using Bessel's correction to calculate an unbiased estimate of the population variance from a finite sample of ''n'' observations, the formula is: : Therefore, a naive algorithm to calculate the estimated variance is given by the following: * Let * For each datum : * * * * * * * This algorithm can easily be adapted to compute the variance of a finite population: simply divide by ''N'' instead of ''n'' − 1 on the last line. Because and can be very similar numbers, cancellation can lead to the precision of the result to be much less than the inherent precision of the floating-point arithmetic used to perform the computation. Thus this algorithm should not be used in practice. This is particularly bad if the standard deviation is small relative to the mean. However, the algorithm can be improved by adopting the method of the assumed mean. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「algorithms for calculating variance」の詳細全文を読む スポンサード リンク
|